package cn.edu.zzuli.admin.service.impl;

import cn.edu.zzuli.admin.mapper.ComplaintMessageMapper;
import cn.edu.zzuli.admin.service.ComplaintMessageService;
import cn.edu.zzuli.model.dto.admin.ComDto;
import cn.edu.zzuli.model.dto.admin.ComplaintDto;
import cn.edu.zzuli.model.entity.ComplaintInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ComplaintMessageServiceImpl extends ServiceImpl<ComplaintMessageMapper, ComplaintInfo> implements ComplaintMessageService {

    @Override
    public Page<ComplaintDto> findAll(Integer page, Integer limit) {
        Page<ComplaintDto> dtoPage = new Page<>(page,limit);
        Page<ComplaintDto> pages = baseMapper.selectListMix(dtoPage);
        return pages;
    }


    @Override
    public ComDto findComDtoById(Integer id) {
        ComDto comDto = baseMapper.selectComDto(id);
        List<String> list = new ArrayList<>();
        list.add(comDto.getUrl());
        if(comDto.getUrl2() != null){
            list.add(comDto.getUrl2());
        }
        if(comDto.getUrl3() != null){
            list.add(comDto.getUrl3());
        }
        comDto.setUrls(list);
        return comDto;
    }
}
